package io.wongxd.solution.util.network

import android.os.SystemClock

enum class NetworkType {
    None,
    Cellular,
    Wifi,
    Fake,
    Unknown
}

data class NetworkState(
    val networkType: NetworkType,
    val isValid: Boolean,
    val uuid: String,
    val updateTime: Long
) {
    companion object {

        fun none() = NetworkState(
            NetworkType.None,
            false,
            "",
            SystemClock.elapsedRealtime()
        )
    }

    val isConnected: Boolean = networkType != NetworkType.None

    override fun toString(): String {
        return when (networkType) {
            NetworkType.Wifi -> "wifi"
            NetworkType.Cellular -> "cellular"
            NetworkType.Unknown -> "unknown"
            NetworkType.Fake -> "fake"
            else -> "none"
        }
    }
}
